﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// Fwmmyhsr
    /// </summary>
    public class Fwmmyhsr
    {


        /// <summary>
        /// 组织机构DAL
        /// </summary>
        private readonly DAL.Fwmmyhsr dal = new DAL.Fwmmyhsr();

        /// <summary>
        /// 得到一个对象实体
        /// <creator>chenly</creator>
        /// <date>2013-8-1</date>
        /// </summary>
        /// <param name="id">主键</param> 
        /// <returns>返回Model</returns>
        public Model.Fwmmyhsr GetModel(decimal id)
        {

            return dal.GetModel(id);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-8-1</date>
        /// <param name="model">model对象</param>
        /// <returns>对象的个数</returns>
        public decimal Add(ElingOA6_Admin_DSJCJ.Model.Fwmmyhsr model)
        {
            return dal.Add(model);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-8-1</date>
        /// <param name="id">主键</param>
        /// <returns>是否删除</returns>
        public bool Delete(decimal id)
        {

            return dal.Delete(id);
        }

        /// <summary>
        /// 批量删除数据 
        /// <creator>chenly</creator>
        /// <date>2013-8-1</date>
        /// </summary>
        /// <param name="idArray">id数组</param>
        public void DeleteMany(string[] idArray)
        {
            dal.DeleteMany(idArray);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-8-1</date>
        /// <param name="model">model对象</param>
        /// <returns>是否更新</returns>
        public bool Update(ElingOA6_Admin_DSJCJ.Model.Fwmmyhsr model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// /// <summary>
        ///  获得数据列表
        /// <creator>chenly</creator>
        /// <date>2013-8-1</date>
        /// </summary>
        /// <param name="dt">一张DataTable</param>
        /// <returns>返回Model</returns>
        public List<Model.Fwmmyhsr> DataTableToListFwmmyhsr(DataTable dt)
        {
            List<Model.Fwmmyhsr> modelList = new List<Model.Fwmmyhsr>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.Fwmmyhsr model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Fwmmyhsr();

                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = decimal.Parse(dt.Rows[n]["id"].ToString());
                    } if (dt.Rows[n]["khyh"] != null && dt.Rows[n]["khyh"].ToString() != "")
                    {
                        model.khyh = dt.Rows[n]["khyh"].ToString();
                    }
                    if (dt.Rows[n]["srbz"] != null && dt.Rows[n]["srbz"].ToString() != "")
                    {
                        model.srbz = dt.Rows[n]["srbz"].ToString();
                    }
                    if (dt.Rows[n]["srje"] != null && dt.Rows[n]["srje"].ToString() != "")
                    {
                        model.srje = decimal.Parse(dt.Rows[n]["srje"].ToString());
                    }
                    if (dt.Rows[n]["srsj"] != null && dt.Rows[n]["srsj"].ToString() != "")
                    {
                        model.srsj = DateTime.Parse(dt.Rows[n]["srsj"].ToString());
                    }

                    modelList.Add(model);
                }
            }
            return modelList;
        }
        /// <summary>
        /// 获取银行收支情况
        /// </summary>
        /// <param name="stratDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <returns></returns>
        public DataSet GetBankPayBalance(string stratDate, string endDate)
        {
            return dal.GetBankPayBalance(stratDate, endDate);
        }
        /// <summary>
        /// 获取财政补贴情况
        /// </summary>
        /// <param name="stratDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <returns></returns>
        public DataSet GetFiscalSubsidies(string stratDate, string endDate) 
        { 
            return dal.GetFiscalSubsidies(stratDate, endDate); 
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="yyyy"></param>
        /// <param name="mm"></param>
        /// <returns></returns>
        public DataSet GetNextDate(string yyyy, string mm)
        {
            return dal.GetNextDate(yyyy, mm);
        }

        public DataSet GetPreDate(string yyyy, string mm)
        {
            return dal.GetPreDate(yyyy, mm);
        }
    }
}
